package com.ruoyi.stock2.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock2.domain.TRADEDATA2;
import com.ruoyi.stock2.service.ITRADEDATA2Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 交易数据2Controller
 * 
 * @author ruoyi
 * @date 2020-03-01
 */
@Controller
@RequestMapping("/stock2/TRADEDATA2")
public class TRADEDATA2Controller extends BaseController
{
    private String prefix = "stock2/TRADEDATA2";

    @Autowired
    private ITRADEDATA2Service tRADEDATA2Service;

    @RequiresPermissions("stock2:TRADEDATA2:view")
    @GetMapping()
    public String TRADEDATA2()
    {
        return prefix + "/TRADEDATA2";
    }

    /**
     * 查询交易数据2列表
     */
    @RequiresPermissions("stock2:TRADEDATA2:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TRADEDATA2 tRADEDATA2)
    {
        startPage();
        List<TRADEDATA2> list = tRADEDATA2Service.selectTRADEDATA2List(tRADEDATA2);
        return getDataTable(list);
    }

    /**
     * 导出交易数据2列表
     */
    @RequiresPermissions("stock2:TRADEDATA2:export")
    @Log(title = "交易数据2", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TRADEDATA2 tRADEDATA2)
    {
        List<TRADEDATA2> list = tRADEDATA2Service.selectTRADEDATA2List(tRADEDATA2);
        ExcelUtil<TRADEDATA2> util = new ExcelUtil<TRADEDATA2>(TRADEDATA2.class);
        return util.exportExcel(list, "TRADEDATA2");
    }

    /**
     * 新增交易数据2
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存交易数据2
     */
    @RequiresPermissions("stock2:TRADEDATA2:add")
    @Log(title = "交易数据2", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TRADEDATA2 tRADEDATA2)
    {
        return toAjax(tRADEDATA2Service.insertTRADEDATA2(tRADEDATA2));
    }

    /**
     * 修改交易数据2
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TRADEDATA2 tRADEDATA2 = tRADEDATA2Service.selectTRADEDATA2ById(id);
        mmap.put("tRADEDATA2", tRADEDATA2);
        return prefix + "/edit";
    }

    /**
     * 修改保存交易数据2
     */
    @RequiresPermissions("stock2:TRADEDATA2:edit")
    @Log(title = "交易数据2", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TRADEDATA2 tRADEDATA2)
    {
        return toAjax(tRADEDATA2Service.updateTRADEDATA2(tRADEDATA2));
    }

    /**
     * 删除交易数据2
     */
    @RequiresPermissions("stock2:TRADEDATA2:remove")
    @Log(title = "交易数据2", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tRADEDATA2Service.deleteTRADEDATA2ByIds(ids));
    }
}
